﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Data.Common;
using System.Data.SqlClient;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp1
{
    class Program
    {
        public static object Datatable { get; private set; }

        static void Main(string[] args)
        {
            string connectionString = "server =.;database= huan;uid=sa;pwd=123456";


            SqlConnection sqlConnection = new SqlConnection(connectionString);
            sqlConnection.Open();
            var sqlcommandstring = "select*from student";
            SqlCommand sqlCommand = new SqlCommand(sqlcommandstring,sqlConnection);
            var sdr = sqlCommand.ExecuteReader();
            while (sdr.Read())
            {
                Console.WriteLine("{0}\t{1}\t{2}",sdr["stuid"],sdr["stuname"],sdr["stuage"]);

            }
            sqlConnection.Close();




            SqlDataAdapter sqldataAdapter = new SqlDataAdapter(sqlcommandstring,connectionString);

            DataTable DDD = new DataTable();


            sqldataAdapter.Fill(DDD);
            Console.WriteLine("{0}\t{1}\t{2}\t{3}", sdr["stuid"], sdr["stuname"], sdr["stuage"]);


            Console.WriteLine();


            Console.WriteLine();


            for (int i = 0; i < DDD.Rows.Count;i++) 
                {
                Console.WriteLine("{0}\t{1}\t{2}\t{3}", DDD.Rows[i]["id"], DDD.Rows[i]["Username"], DDD.Rows[i]["Password"], DDD.Rows[i]["Createdtime"]);
            }
            Console.WriteLine("数据");
            DateaBestHelp.jian();



            DateaBestHelp bd = new DateaBestHelp();
            bd.jin();
        }
    }
}
